package in;

import java.util.Stack;


    /*int getKLevelNodeCount(TreeNode root,int k) {
        if(root==null)
            return 0;
        if(k==1)
            {
                reutrn 1;
            }
        return getKLevelNodeCount(root.left,k-1)+getKLevelNodeCount(root.right,k-1)

            }




//public class MinStack
//{
    Stack<Integer> a;
    Stack<Integer>MinStack;

    public MinStack() {
        a=new Stack<>();
        MinStack=new Stack<>();


    }

    public void push(int val) {
        a.push(val);
        if(MinStack.empty())
        {
            MinStack.push(val);
        }
        if(val<=MinStack.peek())
        {
            MinStack.push(val);
        }


    }

    public void pop() {
        if(MinStack.empty())
        {
            return;
        }
        else
        {
            MinStack.pop();
        }





    }

    public int top() {
        if(MinStack.empty())
        {
            return -1;
        }
        return MinStack.peek();

    }

    public int getMin() {
        if(MinStack.empty())
        {
            return -1;
        }
        return MinStack.peek();


    }




}
    /*public boolean isValid(String s) {
        Stack<Character>a=new Stack<>();
        int i=0;
        for(i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if(ch=='('||ch=='{'||ch=='[')
            {
                a.push(ch);
            }
            else
            {

                if(ch==')'&&a.peek()=='('||ch=='}'&&a.peek()=='{'||ch==']'&&a.peek()=='[')
                {
                    a.pop();
                }
                else
                {
                    return false;
                }

            }
        }
        if(!a.empty())
        {
            return false;
        }
        return true;




    }
    

class text{
      public static void main(String[] args) {
          MinStack a=new MinStack();
          a.push(1);
          a.push(2);
          a.push(-1);
          int x=a.getMin();
          System.out.println(x);


      }
       public static void main1(String[] args) {
           String s="()";
           boolean a=isValid(s);



       }
   }














